package com.wjs.CarolSecKill.utils;

import org.apache.commons.codec.digest.DigestUtils;

/**
 * md5加密工具类
 */
public class Md5Utils {
    private static final String slat="1a2b3c4d";

    public static String md5(String src){
        return DigestUtils.md5Hex(src);
    }

    public static String inputPassToFormPass(String inputPass){
        String str=""+slat.charAt(0)+slat.charAt(2)+inputPass+slat.charAt(5) + slat.charAt(4);
        return md5(str);
    }

    public static String formPassToDBPass(String formPass,String slat){
        String str=""+slat.charAt(0)+slat.charAt(2)+formPass+slat.charAt(5) + slat.charAt(4);
        return md5(str);
    }

    public static String inputPassToDbPass(String inputPass,String slatDB){
        String formPass = inputPassToFormPass(inputPass);
        String dbPass = formPassToDBPass(formPass, slatDB);
        return dbPass;
    }

    public static void main(String[] args) {
        System.out.println(inputPassToFormPass("123456"));
        System.out.println(formPassToDBPass("d3b1294a61a07da9b49b6e22b2cbd7f9","1a2b3c4d"));
        System.out.println(inputPassToDbPass("123456","1a2b3c4d"));
    }
}
